import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const modulesFiles: any = require.context('./modules', true, /\.ts$/)
const modules: any = modulesFiles.keys().reduce((modules: any, modulePath: any) => {
  const moduleName: any = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value: any = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {})

const store = new Vuex.Store({
  modules
})

export default store
